/**
 * Created by Administrator on 2017/5/17.
 */

var indexs=3;
$(function(){
    index3();
});

var xiaopingNgengxin;
var dapingNgengxin;
var xiaopingNgengxinN;
var dapingNgengxinN;
function index3(){
    //3
    clearInterval(xiaopingNgengxin);
    clearInterval(dapingNgengxin);
    clearInterval(xiaopingNgengxinN);
    clearInterval(dapingNgengxinN);

    getcountS();
    gengxinpicS();
    getcountN();
    gengxinpicN();

    xiaopingNgengxin = setInterval(getcountS,30000);
    dapingNgengxin = setInterval(gengxinpicS,60000);
    xiaopingNgengxinN = setInterval(getcountN,30000);
    dapingNgengxinN = setInterval(gengxinpicN,60000);
}

//小屏自动 手动推送 配置---南区
function xiaopingsendS(obj){
    var val = $(obj).val();
    if(val == 0){//启动自动推送
        //将车位接口自动推送标识位改成1
        var type = "sm1";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){
        });

    }else if(val == 1){//关闭自动推送
        //清除定时任务
        //clearInterval(xiaopingNgengxin);
        var type = "sm2";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
    }
}
//小屏自动 手动推送 配置---北区
function xiaopingsendN(obj){
    var val = $(obj).val();
    if(val == 0){//启动自动推送
        //将车位接口自动推送标识位改成1
        var type="nm1";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });

    }else if(val == 1){//关闭自动推送
        //清除定时任务
        //clearInterval(xiaopingNgengxinN);
        var type="nm2";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
    }
}
function getcountS(){
    //获取车位数static数据
    $.get(baseURL + "screen/push/getParkCountS", function(r){
        var list = r.list;
        $("#bigparking").html(list[0]);
        $("#smallparking").html(list[1]);
    });

}
function getcountN(){
    //获取车位数static数据
    $.get(baseURL + "screen/push/getParkCountN", function(r){
        var list = r.list;
        $("#bigparkingN").html(list[0]);
        $("#smallparkingN").html(list[1]);
    });
}
//提示信息的显示--南区
function tishiS(obj){
    if($(obj).val()==24){
        $("#tishi1S").css("display","");
        $("#tishi2S").css("display","none");
    }else{
        $("#tishi2S").css("display","");
        $("#tishi1S").css("display","none");
    }
}
//提示信息的显示--北区
function tishiN(obj){
    if($(obj).val()==24){
        $("#tishi1N").css("display","");
        $("#tishi2N").css("display","none");
    }else{
        $("#tishi2N").css("display","");
        $("#tishi1N").css("display","none");
    }
}
//小屏推送S
function sengInfoSmallS(){
    var val1 = $("#tiaojian1SN input:checked").val();
    if(val1 == 0){
        alert("请先将推送模式设置为手动");
        return;
    }
    var val2 = $("#tiaojian2SN input:checked").val();
    var val3 = $("#tiaojian3SN input:checked").val();
    var color = "red";
    if(val3 == 1){
        color = "green";
    }else if (val3 == 2){
        color = "yellow";
    }
    var val4 = $("#tiaojian4SN").val();
    $("#infoS").html("<p style='color:"+color+";font-size: "+val2+"px;'>"+val4+"</p>");
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushsmallS",
        data: {
            fontSize:val2,
            fontColor:val3,
            info:val4
        },
        success: function(n) {

        }
    });
}
//小屏推送N
function sengInfoSmallN(){
    var val1 = $("#tiaojian1N input:checked").val();
    if(val1 == 0){
        alert("请先将推送模式设置为手动");
        return;
    }
    var val2 = $("#tiaojian2N input:checked").val();
    var val3 = $("#tiaojian3N input:checked").val();
    var color = "red";
    if(val3 == 1){
        color = "green";
    }else if (val3 == 2){
        color = "yellow";
    }
    var val4 = $("#tiaojian4N").val();
    $("#infoN").html("<p style='color:"+color+";font-size: "+val2+"px;'>"+val4+"</p>");
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushsmallN",
        data: {
            fontSize:val2,
            fontColor:val3,
            info:val4
        },
        success: function(n) {

        }
    });
}
//大屏自动-手动配置
function dapingsendS(obj){
    var val = $(obj).val();
    if(val == 0){
        //修改标识
        var type="sb1";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
    }else{
        //修改标识
        var type="sb2"
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
    }
}
//大屏自动-手动配置
function dapingsendN(obj){
    var val = $(obj).val();
    if(val == 0){
        //修改标识
        var type="nb1"
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
    }else{
        //修改标识
        var type="nb2";
        $.get(baseURL + "screen/push/setScreenStatus/"+type, function(r){

        });
    }
}
//更新大屏图片
function gengxinpicS(){
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushbigS",
        data: {

        },
        success: function(r) {
            var list = r.list;
            if(list.length ==1){
                $("#statusbigS").html("当前屏幕状态：离线");
            }else{
                $("#statusbigS").html("当前屏幕状态：在线");
                $("#dapingpic").attr("src","/image1/"+list[1]);
            }

        }
    });
}
//更新大屏图片--北区
function gengxinpicN(){
    $.ajax({
        type: "POST",
        url: "../../screen/push/pushbigN",
        data: {

        },
        success: function(r) {
            var list = r.list;
            if(list.length ==1){
                $("#statusbigN").html("当前屏幕状态：离线");
            }else{
                $("#statusbigN").html("当前屏幕状态：在线");
                $("#dapingpicN").attr("src","/image2/"+list[1]);
            }

        }
    });
}
